package top.hekun.study.core.visitor.simple;

import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.FieldVisitor;
import org.objectweb.asm.MethodVisitor;

/**
 * 〈删除字段〉
 *
 * @author: Sakura
 * @date: 2023/5/8
 */
public class MyClassVisitor3 extends ClassVisitor {
    public MyClassVisitor3(int apiVersion, ClassVisitor classWriter) {
        super(apiVersion, classWriter);
    }

    @Override
    public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) {
        System.out.println("MyClassVisitor3:visit");
        super.visit(version, access, name, signature, superName, interfaces);
    }

    @Override
    public FieldVisitor visitField(int access, String name, String descriptor, String signature, Object value) {
        System.out.println("MyClassVisitor3:visitField -- " + name);
        if ("intValue".equals(name)){
            return null;
        }
        return super.visitField(access, name, descriptor, signature, value);
    }

    @Override
    public MethodVisitor visitMethod(int access, String name, String descriptor, String signature, String[] exceptions) {
        System.out.println("MyClassVisitor3:visitMethod -- " + name + " -- " + descriptor);
        return super.visitMethod(access, name, descriptor, signature, exceptions);
    }

    @Override
    public void visitEnd() {
        System.out.println("MyClassVisitor3:visitEnd");

        super.visitEnd();
    }
}
